<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Category_id')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-category_id" data-rule="required" data-source="category/selectpage"  class="form-control selectpage" name="row[category_id]" type="text" value="{$row.category_id|htmlentities}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Image')}:</label>
        <div class="col-xs-12 col-sm-8">
            <div class="input-group">
                <input id="c-image" data-rule="required" class="form-control" size="50" name="row[image]" type="text" value="{$row.image|htmlentities}">
                <div class="input-group-addon no-border no-padding">
                    <span><button type="button" id="faupload-image" class="btn btn-danger faupload" data-input-id="c-image" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp" data-multiple="false" data-preview-id="p-image"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
                </div>
                <span class="msg-box n-right" for="c-image"></span>
            </div>
            <ul class="row list-inline faupload-preview" id="p-image"></ul>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Name')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-name" data-rule="required" class="form-control" name="row[name]" type="text" value="{$row.name|htmlentities}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Sweetness')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-sweetness" data-rule="required" class="form-control" name="row[sweetness]" type="number" value="{$row.sweetness|htmlentities}">
            <div style="margin-top: 6px; color: #555555;">注：1-6之间的数字</div>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('规格')}:</label>
        <div class="col-xs-12 col-sm-8">
            <dl class="fieldlist" data-template="basictpl" data-name="row[attr]">
                <dd>
                    <ins>{:__('规格名称')}</ins>
                    <ins>{:__('价格')}</ins>
                    <ins>{:__('分享人数')}</ins>
                    <ins>{:__('餐具')}</ins>
                </dd>
                <dd><a href="javascript:;" class="btn btn-sm btn-success btn-append"><i class="fa fa-plus"></i> {:__('Append')}</a></dd>
                <!-- &lt;!&ndash;请注意 dd和textarea间不能存在其它任何元素，实际开发中textarea应该添加个hidden进行隐藏&ndash;&gt;-->
                <textarea name="row[attr]" style="display: none;"  class="form-control" cols="30" rows="5">{$goods_attr}</textarea>
            </dl>
            <script id="basictpl" type="text/html">
                <dd class="form-inline">
                    <input  type="hidden" name="<%=name%>[<%=index%>][id]" class="form-control" value="<%=row.id%>" />
                    <ins><input  type="text" name="<%=name%>[<%=index%>][attr_name]" class="form-control" value="<%=row.attr_name%>" placeholder="规格名称" /></ins>
                    <ins><input  type="number" onkeyup="value=value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')" name="<%=name%>[<%=index%>][price]" class="form-control" value="<%=row.price%>" placeholder="价格"/></ins>
                    <ins><input  type="text" name="<%=name%>[<%=index%>][share_num]" class="form-control" value="<%=row.share_num%>" placeholder="分享人数"/></ins>
                    <ins><input  type="text" name="<%=name%>[<%=index%>][tableware_num]" class="form-control" value="<%=row.tableware_num%>" placeholder="餐具数量"/></ins>
                    <!-- &lt;!&ndash;下面的两个按钮务必保留&ndash;&gt;-->
                    <span class="btn btn-sm btn-danger btn-remove" onclick="del(<%=row.id%>)"><i class="fa fa-times"></i></span>
                </dd>
            </script>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Content')}:</label>
        <div class="col-xs-12 col-sm-8">
            <textarea id="c-content" data-rule="required" class="form-control editor" rows="5" name="row[content]" cols="50">{$row.content|htmlentities}</textarea>
        </div>
    </div>
    <div class="form-group layer-footer">
        <label class="control-label col-xs-12 col-sm-2"></label>
        <div class="col-xs-12 col-sm-8">
            <button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
            <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
        </div>
    </div>
</form>
<script type="application/javascript">
    function del(id){
        $.post('/admin/goods/del_attr',{id:id},function(result){
            Layer.msg(result.msg);
        })
    }
</script>

